home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2004 March / PCWMAR04.iso / Software / Resources / JawsPDF Creator / JawsPdfCreatorEn.exe / Disk1 / data1.cab / InstDirResource / procset / opi2.ps < prev    next >
Encoding:
Text File  |  2003-08-08  |  10.4 KB  |  362 lines

  1. %!
  2. %%VMusage: 0 0
  3. %%VMlocation: global
  4. %%
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. %%                                    %%
  7. %% OPIProcSet: procedures to go into CommentDict to enable basic    %%
  8. %% OPI processing, for OPI version 2.0. This procset should be able %%
  9. %% to handle both version 1 and version 2 comments as well as files %%
  10. %% that include both.                            %%
  11. %%                                    %%
  12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  13.  
  14.  
  15. /OPI2.0ProcSet <<
  16.  
  17. /Initialise {
  18.   userdict /OPIinitialised? known {
  19.     userdict /OPIinitialised? get
  20.   } {
  21.     false
  22.   } ifelse
  23.   not {
  24.     currentglobal false setglobal
  25.     userdict /OPIdocomment {
  26.      dup length string cvs
  27.       3 -1 roll exch anchorsearch pop pop
  28.       (: ) anchorsearch pop pop
  29.       OPIdict 3 1 roll put
  30.     } put
  31.     userdict /OPIdoobject_v1 {
  32.       /OPI2.0ProcSet /ProcSet findresource begin DoObject_v1 end
  33.     } put
  34.     userdict /OPIdoobject_v2 {
  35.       /OPI2.0ProcSet /ProcSet findresource begin DoObject_v2 end
  36.     } put
  37.     userdict /OPIdict 12 dict put
  38.     userdict /OPIinitialised? true put
  39.     setglobal
  40.   } if
  41. } bind
  42.  
  43. /Known {
  44.   2 copy known {
  45.     1 index exch get true
  46.   } {
  47.     pop false
  48.   } ifelse
  49. } bind
  50.  
  51. %%
  52. %% OPIdict filename => OPIdict paramsdict file true
  53. %% See the manual before adding file types to this procedure.
  54. %%
  55. /FindFile {
  56.   mark {
  57.     8 dict
  58.     2 index dup 0 get 16#28 eq {cvx exec} if
  59.     (r) file 1 index /TIFFDecode filter
  60.   } stopped {
  61.     cleartomark false
  62.   } {
  63.     4 2 roll pop pop true
  64.   } ifelse
  65. } bind
  66.  
  67. %%
  68. %% OPIdict paramsdict file => -
  69. %%
  70. %% The code below does not always manage to do the right thing if the
  71. %% Distilled keyword is present.  This is largely because not enough
  72. %% information is recorded in a PDF OPI dictionary.  In this case we
  73. %% execute stop to cause the low res image to be used instead.
  74. %%
  75. /DoImage {
  76.   exch begin
  77.   8 dict begin
  78.   /ImageType 1 def
  79.   /Width Width def
  80.   /Height Height def
  81.   /DataSource exch def
  82.   /BitsPerComponent BitsPerComponent def
  83.   /ImageMask false def
  84.  
  85.   gsave
  86.   /ALDImagePosition Known {
  87.     cvx exec
  88.     6 index sub exch 7 index sub exch
  89.     6 -2 roll
  90.     6 index sub exch 7 index sub exch
  91.     6 -2 roll pop pop
  92.     6 -2 roll matrix astore concat
  93.     0 0 1 1 rectclip
  94.   } if
  95.  
  96.   dup /ALDImageDimensions known
  97.   1 index /ALDImageCropRect known and {
  98.     dup /ALDImageDimensions get cvx exec
  99.     2 index /ALDImageCropRect get cvx exec
  100.     3 -1 roll sub 3 index exch div
  101.     3 1 roll exch sub 3 index exch div
  102.     exch scale
  103.     2 index /ALDImageCropRect get cvx exec
  104.     4 1 roll pop pop 3 index div neg
  105.     exch 2 index sub 2 index div
  106.     translate
  107.     pop pop
  108.   } if
  109.  
  110.   /ALDImageOverprint Known {cvx exec setoverprint} if
  111.  
  112.   /ImageMatrix [Width 0 0 Height neg 0 Height] def
  113.  
  114.   Photometric 2 lt 1 index /Version get 2 eq and 1 index /Distilled known not and {
  115.     /ImageInks Known {
  116.       token {
  117.         exch pop /monochrome eq
  118.       } {
  119.         false
  120.       } ifelse
  121.     } {
  122.       false
  123.     } ifelse
  124.   } {
  125.     false
  126.   } ifelse
  127.   {
  128.     Width Height BitsPerComponent ImageMatrix DataSource
  129.     end end
  130.     OPIimage
  131.   } {
  132.     Photometric 2 lt {
  133.       /ALDImageTint Known {cvx exec} {1} ifelse /ImageTint exch def
  134.       /ALDImageGrayMap Known {
  135.         [ [ 3 -1 roll cvx exec ] /exch load 1 index length
  136.         Photometric 0 eq {1 /exch load /sub load 4 -1 roll} if
  137.         1 sub /mul load /cvi load /get load 65535 /div load] cvx settransfer
  138.       } if
  139.       /Decode [0 ImageTint Photometric 0 eq {exch} if ] def
  140.       BitsPerComponent 1 eq {
  141.         /ALDImageTransparency Known {cvx exec} {true} ifelse
  142.         /ImageMask exch def
  143.       } if
  144.       /ImageInks Known {
  145.         token pop
  146.         (monochrome) eq {
  147.           token pop
  148.           dup 1 eq {
  149.             cvx exec
  150.             /ImageTint exch def
  151.             false currentpagedevice /SeparationOrder get {
  152.               1 index eq {pop true exit} if
  153.             } forall
  154.             not {stop} if
  155.             [/Separation 3 -1 roll /DeviceGray {}] setcolorspace
  156.           } {
  157.         4 eq {
  158.               cvx exec
  159.               4 dict begin 4 {def} repeat
  160.               currentdict end
  161.               dup /Cyan known 1 index /Magenta known and
  162.               1 index /Yellow known and 1 index /Black known and
  163.               not {stop} if
  164.               begin
  165.               [/Indexed /DeviceCMYK 255 [ 255 /div Cyan Magena Yellow Black end
  166.               systemdict /stdtinttransform get] cvx ] setcolorspace
  167.               ImageMask {
  168.                 255 ImageTint mul round cvi setcolor
  169.               } {
  170.                 /Decode [0 255 ImageTint mul round cvi Photometric 0 ne {exch} if] def
  171.               } ifelse
  172.             } {
  173.               mark exch cvx exec counttomark 2 idiv dup dict begin {
  174.                 dup 0 eq {pop pop} {
  175.                   exch (Hexachrome ) anchorsearch {pop} if exch def
  176.                 } ifelse
  177.               } repeat
  178.               currentdict
  179.               true 1 index {
  180.                 false currentpagedevice /SeparationOrder get {
  181.                   1 index eq {pop true exit} if
  182.                 } forall
  183.                 not {stop} if
  184.               } forall
  185.               [/Indexed [/DeviceN [currentdict {pop} forall]
  186.               /DeviceGray [currentdict length {pop} /repeat load 1] cvx bind]
  187.               [255 /div load currentdict {
  188.                 exch pop /dup load exch /mul load /exch load} forall /pop load
  189.               ] cvx bind] setcolorspace
  190.               end
  191.               /Decode [0 255 ImageTint mul round cvi Photometric 0 ne {exch} if] def
  192.             } ifelse
  193.           } ifelse
  194.         } {
  195.           pop [/Separation /All /DeviceCMYK {dup dup dup}] setcolorspace
  196.         } ifelse
  197.       } {
  198.         /ALDImageColor Known {cvx exec} {0 0 0 1 (Black)} ifelse
  199.         6 -1 roll /ALDImageColorType Known not {(Spot)} if exch 7 1 roll
  200.         dup (Separation) eq {
  201.           pop pop [/Separation /All /DeviceCMYK {dup dup dup}] setcolorspace
  202.         } {
  203.           (Process) eq {
  204.             pop
  205.             [/Indexed /DeviceCMYK 255 [ 255 /div load 11 -4 roll
  206.             systemdict /stdtinttransform get] cvx ] setcolorspace
  207.             ImageMask {
  208.               255 ImageTint mul round cvi setcolor
  209.             } {
  210.               /Decode [0 255 ImageTint mul round cvi Photometric 0 ne {exch} if] def
  211.             } ifelse
  212.           } {
  213.             [/Separation 3 -1 roll /DeviceCMYK [ 9 -4 roll
  214.             systemdict /stdtinttransform get] cvx ] setcolorspace
  215.           } ifelse
  216.         } ifelse
  217.       } ifelse
  218.     } if
  219.     Photometric 2 eq {
  220.       /DeviceRGB setcolorspace
  221.       /Decode [0 1 0 1 0 1] def
  222.     } if
  223.     Photometric 3 eq {
  224.       [/Indexed /DeviceRGB Palette length 3 idiv 1 sub Palette] setcolorspace
  225.       /Decode [0 Palette length 3 idiv 1 sub] def
  226.     } if
  227.     Photometric 5 eq {
  228.       /DeviceCMYK setcolorspace
  229.       /Decode [0 1 0 1 0 1 0 1] def
  230.     } if
  231.     /ALDImageOperation Known {
  232.       cvx exec
  233.     } {
  234.       currentdict ImageMask end end
  235.       {imagemask} {image} ifelse
  236.     } ifelse
  237.   } ifelse
  238.   pop
  239.   grestore
  240. } bind
  241.  
  242.  
  243. /CommentDict <<
  244.   /ALDImageFileName {/ALDImageFileName dup OPIdocomment}
  245.   /ALDImageID {/ALDImageID dup OPIdocomment}
  246.   /ALDImageDimensions {/ALDImageDimensions dup OPIdocomment}
  247.   /ALDImageCropRect {/ALDImageCropRect dup OPIdocomment}
  248.   /ALDImagePosition {/ALDImagePosition dup OPIdocomment}
  249.   /ALDImageColor {/ALDImageColor dup OPIdocomment}
  250.   /ALDImageColorType {/ALDImageColorType dup OPIdocomment}
  251.   /ALDImageTint {/ALDImageTint dup OPIdocomment}
  252.   /ALDImageOverprint {/ALDImageOverprint dup OPIdocomment}
  253.   /ALDImageTransparency {/ALDImageTransparency dup OPIdocomment}
  254.   /ALDImageGrayMap {/ALDImageGrayMap dup OPIdocomment}
  255.   /BeginObject {pop OPIdoobject_v1}
  256.   /ImageFileName {/ALDImageFileName /ImageFileName OPIdocomment}
  257.   /MainImage {/ALDImageID /MainImage OPIdocomment}
  258.   /ImageDimensions {/ALDImageDimensions /ImageDimensions OPIdocomment}
  259.   /ImageCropRect {/ALDImageCropRect /ImageCropRect OPIdocomment}
  260.   /ImageOverprint {/ALDImageOverprint /ImageOverprint OPIdocomment}
  261.   /ImageInks {/ImageInks dup OPIdocomment}
  262.   /Distilled {pop OPIdict /Distilled true put}
  263.   /BeginIncludedImage {pop OPIdoobject_v2}
  264. >>
  265.  
  266. /DoObject_v1 {
  267.   2 dict begin
  268.   /opi_junk 2048 string def
  269.   userdict /OPIdict get dup /ALDImageFileName known
  270.   exch /ALDImageID known or {
  271.     currentfile opi_junk {readline} stopped {
  272.       pop
  273.     } {
  274.       pop
  275.       /opi_nextline exch def
  276.       opi_nextline (%%BeginOPI: 2.0) eq {
  277.         userdict /OPIdict get dup {pop 1 index exch undef} forall
  278.       } {
  279.         userdict /OPIdict get
  280.         dup /Version 1.3 put
  281.         /ALDImageID Known not {
  282.           /ALDImageFileName Known pop
  283.         } if
  284.         dup type /dicttype ne {
  285.           mark 3 1 roll
  286.           FindFile {
  287.             {DoImage} stopped
  288.           } {
  289.             true
  290.           } ifelse
  291.           {
  292.             (%%[ OPI substitution failed; using low resolution image ]%%) = flush
  293.             pop
  294.             opi_nextline length 0 gt {opi_nextline 0 get 16#25 ne} {false} ifelse {
  295. %            opi_nextline 0 get 16#25 ne {
  296.               opi_nextline end cvx exec
  297.               1 dict begin
  298.             } if
  299.           } {
  300.             opi_nextline (%%EndObject) ne {
  301.               {
  302.                 currentfile opi_junk {readline} stopped {
  303.                   pop pop
  304.                 } {
  305.                    not {stop} if
  306.                    (%%EndObject) eq {exit} if
  307.                 } ifelse
  308.               } loop
  309.             } if
  310.           } ifelse
  311.           cleartomark
  312.         } {
  313.           pop
  314.         } ifelse
  315.       } ifelse
  316.     } ifelse
  317.   } if
  318.   end
  319. } bind
  320.  
  321. /DoObject_v2 {
  322.   userdict /OPIdict get
  323.   dup /Version 2 put
  324.   /ALDImageID Known not {
  325.     /ALDImageFileName Known pop
  326.   }{
  327.     exch pop
  328.   } ifelse
  329.   dup type /dicttype ne {
  330.     mark 3 1 roll
  331.     FindFile {
  332.       {DoImage} stopped
  333.     } {
  334.       true
  335.     } ifelse
  336.     {
  337.       (%%[ OPI substitution failed; using low resolution image ]%%) = flush
  338.     } {
  339.       1 dict begin
  340.       /opi_junk 2048 string def
  341.       {
  342.         currentfile opi_junk {readline} stopped {
  343.           pop pop
  344.         } {
  345.           not {stop} if
  346.           (%%EndOPI) eq {exit} if
  347.         } ifelse
  348.       } loop
  349.       end
  350.     } ifelse
  351.     cleartomark
  352.   } {
  353.     pop
  354.   } ifelse
  355.   userdict /OPIdict 12 dict put
  356. } bind
  357.  
  358. >> /ProcSet defineresource
  359.  
  360. dup /Initialise get exec
  361.  
  362.